package edu.java.homework.hw03.ipj07;

public class Exer01done {

    public static final String VOWELS="AaEeIiOoUuYy";
    /**
     * Print only vowels in string
     * @param args
     */
    public static void main(String[] args) {
	String str="Hello, JaGUar,GuErnIca, YahuuU";
	System.out.println(str);
	System.out.println("\nprintVowels1: ");
	printVowels1(str);
	
	System.out.println("\nprintVowels2: ");
	printVowels2(str);

    }
    
    /**
     *  Print only vowels in string. Use indexOf-API method for realization
     *  
     */
    public static void printVowels1(String str){
	if(str==null){
	    return;
	}
	for(int i=0;i<str.length();i++){
	    char ch=str.charAt(i);
	    if(VOWELS.indexOf(ch)>-1){
		System.out.print(ch + "  ");
	    }
	}
    }
    /**
     * Print only vowels in string. Use switch-operator
     * @param str
     */
    public static void printVowels2(String str){
	if(str==null){
	    return;
	}
	for(int i=0;i<str.length();i++){
	    char ch=str.charAt(i);
	    switch(ch){
        	    case 'A':{
        		System.out.print('A' + "  ");
        		break;
        	    }
        	    case 'a':{
        		System.out.print('a' + "  ");
        		break;
        	    }
        	    case 'E':{
        		System.out.print('E' + "  ");
        		break;
        	    }
        	    case 'e':{
        		System.out.print('e' + "  ");
        		break;
        	    }
        	    case 'I':{
        		System.out.print('I' + "  ");
        		break;
        	    }
        	    case 'i':{
        		System.out.print('i' + "  ");
        		break;
        	    }
        	    case 'O':{
        		System.out.print('O' + "  ");
        		break;
        	    }
        	    case 'o':{
        		System.out.print('o' + "  ");
        		break;
        	    }
        	    case 'U':{
        		System.out.print('U' + "  ");
        		break;
        	    }
        	    case 'u':{
        		System.out.print('u' + "  ");
        		break;
        	    }
        	    case 'Y':{
        		System.out.print('Y' + "  ");
        		break;
        	    }
        	    case 'y':{
        		System.out.print('y' + "  ");
        		break;
        	    }
	    }
	}	
    }
    

}
